package com.tencent.qf.team.controller;

import com.tencent.qf.common.aspect.annotation.ApiLog;
import com.tencent.qf.common.aspect.annotation.Signature;
import com.tencent.qf.common.pojo.HttpResult;
import com.tencent.qf.mybatis.pojo.PageRequest;
import com.tencent.qf.mybatis.pojo.PageResult;
import com.tencent.qf.team.dal.TyShareCodeReview;
import com.tencent.qf.team.dto.request.GuiderShareStatisticRequest;
import com.tencent.qf.team.dto.request.ShareCodeReviewRequest;
import com.tencent.qf.team.dto.response.GuiderSharePaginateResponse;
import com.tencent.qf.team.dto.response.GuiderShareStatisticResponse;
import com.tencent.qf.team.service.GuiderShareCpsService;
import com.tencent.qf.team.service.ShareCodeReviewService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
public class GuiderShareController {

    @Autowired
    private GuiderShareCpsService guiderShareCpsService;
    @Autowired
    private ShareCodeReviewService shareCodeReviewService;

    @PostMapping("/api/team/guiderShareStatistic")
    @ApiLog("推广数据看板聚合数据")
    @ApiOperation("小B分享维度聚合数据")
    public HttpResult<GuiderShareStatisticResponse> guiderShareStatistic(@RequestBody GuiderShareStatisticRequest request) {
        GuiderShareStatisticResponse data = guiderShareCpsService.guiderShareStatistic(request);
        HttpResult<GuiderShareStatisticResponse> result = HttpResult.success(data);
        return result;
    }

    @PostMapping("/api/team/guiderSharePaginate")
    @ApiLog("推广数据看板列表查询")
    public HttpResult<PageResult<GuiderSharePaginateResponse>> guiderSharePaginate(@RequestBody PageRequest<GuiderShareStatisticRequest> request) {
        PageResult<GuiderSharePaginateResponse> data = guiderShareCpsService.guiderSharePaginate(request);
        HttpResult<PageResult<GuiderSharePaginateResponse>> result = HttpResult.success(data);
        return result;
    }

    @Signature
    @ApiLog("查询分享码浏览记录")
    @PostMapping("/api/team/share/reviews")
    public HttpResult<PageResult<TyShareCodeReview>> queryShareReviews(@RequestBody PageRequest<ShareCodeReviewRequest> request) {
        PageResult<TyShareCodeReview> data = shareCodeReviewService.queryShareReviews(request);
        HttpResult<PageResult<TyShareCodeReview>> result = HttpResult.success(data);
        return result;
    }

    @Signature
    @ApiLog("查询用户浏览记录")
    @PostMapping("/api/team/view/records")
    public HttpResult<List<TyShareCodeReview>> queryViewRecords(@RequestBody ShareCodeReviewRequest request) {
        List<TyShareCodeReview> data = shareCodeReviewService.queryViewRecords(request);
        HttpResult<List<TyShareCodeReview>> result = HttpResult.success(data);
        return result;
    }


}
